<?php $this->load->view('inc/header.php');?>
<?php $this->load->view('model/inc_sm.php');?>
<?PHP html_js('jquery.sortable.js');?>

<div class="col-right">
	<div class="opt">
		<a class="wm-ajax" 
			wmtitle="添加属性"
			wmw="500"
			wmh="360"
			href="<?php echo site_url('c=model&m=attr_add&id='.fd('r_model.id'));?>">添加属性	</a>
	</div>

	<div class="box">
		<div class="box-t">
			<span class="fl">
				<a href="<?php echo $pre_url;?>">模型列表</a> &gt; 属性列表</span>
			<span class="fr"><?PHP echo $r_model->title;?></span>
		</div>
		<div class="box-c">
			<form id="frm-attr-ord" action="<?php echo site_url('c=model&m=attr_ord_do');?>">
			<input type="hidden" name="id" value="<?PHP echo fd('r_model.id');?>"/>
			<table class="tbl-list">
				<tr>
					<td width="100">属性名称</td>
					<td width="100">属性标题</td>
					<td width="100">属性类型</td>
					<td>默认值</td>
					<td width="140">操作</td>
				</tr>
			</table>
			<ul class="attr-list">    
				<li style="display:none;"></li>
				<?PHP foreach ($attr as $k => $v):?>
				<li>
					<table class="tbl-list">
						<tr>
							<td width="100"><?php echo $v['title'];?></td>
							<td width="100"><?php echo $v['name'];?></td>
							<td width="100"><?php echo $v['type'];?></td>
							<td><?php echo $v['default'];?></td>
							<td width="140">
								<a class="wm-ajax" 
									wmtitle="编辑"
									wmid="wm-attr-edit"
									wmw="500"
									wmh="360"
									href="<?php echo site_url('c=model&m=attr_edit&id='.fd('r_model.id')).'&i='.$k?>">编辑</a>

								<a class="btn-ajax-confirm" msg='确定要删除此属性吗？' 
									href="<?php echo site_url('c=model&m=attr_del&id='.fd('r_model.id')).'&i='.$k?>">删除</a>
							</td>
						</tr>
					</table>
					<input type="hidden" name="ord[]" value="<?php echo $k;?>"/>
				</li>
				<?php endforeach;?>
			</ul>
			<div class="action" style="display:none;">
				<input id="btn-save-arr-ord" type="button" value="保存"  class="btn-ajax-submit" frmid="frm-attr-ord"/>
			</div>
			</form>
		</div>
		<div id="msg"></div>
	</div>
</div>

<?php $this->load->view('inc/footer.php');?>

<script>
    $('.attr-list').sortable().bind('sortupdate',function(){
    	$('#btn-save-arr-ord').click();
    });
</script>